package org.fisco.bcos.asset.controller;

import org.fisco.bcos.asset.client.CharityDonationClient;
import org.fisco.bcos.asset.resp.AccountInfo;
import org.fisco.bcos.asset.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@RestController
@RequestMapping("/api/account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    @Resource
    private CharityDonationClient client;

    /**
     * 注册用户并返回账户信息
     * @return 账户信息，包含地址、私钥和公钥
     */
    @PostMapping("/register")
    public AccountInfo registerAccount() {
        return accountService.registerAccount();
    }


    @PostMapping("/login")
    public void login(@RequestHeader("privateKey") String privateKey) throws Exception {
        // 处理私钥
        client.initialize(privateKey);
    }
}